import ala from 'ala'
export default {
	// 获取商品视图
	async getProductView(categoryId, priceStyleId) {
		var para = {
			id: ala.getId(),
			userId: ala.userId(),
			priceStyleId: priceStyleId
		}
		if (categoryId) {
			para = {
				...para,
				categoryId: categoryId
			}
		}
		var response = await ala.httpGet('api/ShopStore/GetProductView', para)
		if (response) {
			return response
		}
	},
	async save(jsThis) {
		var data = jsThis.viewModel
		data.product.productExtensions.productCategory = data.category
		data.product.productExtensions.store = data.store
		data.isRegion = data.product.isRegion
		var response = await ala.httpPost('api/ShopStore/EditProduct', data)
		var url = window.location.href
		if (url.indexOf('store') > 0 || url.indexOf('Store') > 0) {
			ala.toMessage(response, '', '', true)
		} else {
			ala.toMessage(response)
		}
	}
}